<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <button id="btn">按钮</button>
    <input type="text" id="inp" />
    <script>
      //  当标签上写了id属性,则现代浏览器会自动指向后面这行获取元素的代码  const btn = document.getElementById('btn')
      btn.onclick = function (e) {
        console.log(e)
      }
      inp.onkeydown = function (e) {
        console.log(e)
      }
    </script>
  </body>
</html>
